<script type="text/javascript">

    jQuery(document).ready(function () {
        jQuery('#mycarousel').jcarousel({
            wrap:'circular', scroll:1
        });
    });

</script>

<div class="form">

    <?php $form = $this->beginWidget('CActiveForm', array(
    'id' => 'topic-form',
    'enableAjaxValidation' => true,
    'htmlOptions' => array('enctype' => 'multipart/form-data'), // ADD THIS
)); ?>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <?php echo CHtml::errorSummary($model); ?>


    <div class="row">
        <?php echo $form->labelEx($model, 'section'); ?>
        <?php echo $form->hiddenField($model, 'section_id'); ?>
        <?php echo $form->dropDownList($model, 'section_id', YumSection::loadItems(), array('disabled' => true));?>
        <?php echo $form->error($model, 'section'); ?>
    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'category'); ?>
        <?php echo $form->dropDownList($model, 'category_id', YumCategory::loadItems(), array('disabled' => true)); ?>
        <?php /*todo:
 //*echo CHtml::dropDownList($model->category_id, 'category', YumCategory::loadItems($model->section_id)); */?>
        <?php echo $form->error($model, 'section'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'title'); ?>
        <?php echo $form->textField($model, 'title', array('size' => 80, 'maxlength' => 128)); ?>
        <?php echo $form->error($model, 'title'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'content'); ?>
        <?php echo CHtml::activeTextArea($model, 'content', array('rows' => 10, 'cols' => 70)); ?>
        <p class="hint"><? echo Yum::t('You may use')?>&nbsp;<a target="_blank"
                                                                href="http://ru.wikipedia.org/wiki/Markdown"><? echo Yum::t('Markdown syntax')?></a>.
        </p>
        <?php echo $form->error($model, 'content'); ?>
    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'city'); ?>
        <?php echo $form->dropDownList($model, 'city_id', YumCity::loadItems()); ?>
        <?php echo $form->error($model, 'city'); ?>
    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'phone');?>
        <?php /*echo $form->textField($model->phones, 'name', array('size' => 80, 'maxlength' => 128)); */?>
        <div id="phones">
            <?php echo $this->renderPartial('_phone_form', array('model' => $model->phones, 'form' => $form)); ?>
            <!--        <div class="phone">
            <?php
/*            for($i=0;$i<sizeof($model->phones);$i++){
                echo $form->textField($model->phones[$i], 'name', array('size' => 80, 'maxlength' => 128));
            }
            */?>-->
        </div>
        <?/*
        echo CHtml::ajaxSubmitButton(Yum::t('add'), CController::createUrl('AddPhone'),
            array('update'=>'#phones','data'=>CJSON::encode($model->phones),'dataType'=>'json'));
            array('update'=>'#phones'));
        */?>
    </div>
    <div class="row">

        <ul id="mycarousel" class="jcarousel-skin-tango">
            <?
            foreach($model->photos as $photo) {
                echo '<li><img width="75" height="75" src="'.$photo->path.'"/></li>';
            }
            ?>
        </ul>

        <?php echo $form->labelEx($model, 'photo'); ?>
        <?php
        $this->widget('CMultiFileUpload', array(
            'name' => 'images',
            'accept' => 'jpg',
            'max' => 3,
            'remove' => Yum::t('remove'),
            'denied' => Yum::t('denied'),
            'duplicate' => Yum::t('duplicate'),
            'htmlOptions' => array('size' => 25),
        ));


        ?>
        <?php /*echo $form->dropDownList($model, 'photos', YumPhoto::loadItems(0)); */?>
        <?php echo $form->error($model, 'photo'); ?>

    </div>

    <div class="row">
        <?
        $this->beginWidget('WorkTimeWidget',array('post_id'=>$model->id),array('class'=>'work_time'));
        $this->endWidget();
        ?>
    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'tags'); ?>
        <?php $this->widget('CAutoComplete', array(
        'model' => $model,
        'attribute' => 'tags',
        'url' => array('suggestTags'),
        'multiple' => true,
        'htmlOptions' => array('size' => 50),
    )); ?>
        <p class="hint">Please separate different tags with commas.</p>
        <?php echo $form->error($model, 'tags'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'status'); ?>
        <?php echo $form->dropDownList($model, 'status', Lookup::items('PostStatus')); ?>
        <?php echo $form->error($model, 'status'); ?>
    </div>

    <div class="row buttons">
        <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->
<script type="text/javascript">
    $(document).ready(function () {
        $('overview').roundabout();
    });
</script>